<template>
  <section class="component assist-button">
    <el-button
      @click="onClickButton"
      class="list-button white-button"
      size="mini"
      type="text"
      v-if="menuChannel !== 44 && menuChannel !== 34"
      >协催申请</el-button
    >
    <el-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
      title="协催申请"
      :visible.sync="dialog"
      append-to-body
      width="800px"
    >
      <assist-apply
        :applyType="applyType.value"
        :caseIds="[caseId]"
        :otherData="otherModel"
        :disabledType="disabledType"
        @close="dialog = false"
      ></assist-apply>
    </el-dialog>
  </section>
</template>
<script lang="ts">
import { Vue, Component, Prop } from "vue-property-decorator";
import AssistApply from "~/components/apply-component/assist-apply.vue";
import { State, namespace } from "vuex-class";
import {
  ApplyType,
  CASE_HALT_CATEGORY,
  MENU_CHANNEL
} from "~/config/enum.config";

const CollectionExecutionModule = namespace("collection-execution");

@Component({
  components: {
    AssistApply
  }
})
export default class AssistButton extends Vue {
  @CollectionExecutionModule.State private caseId;
  @CollectionExecutionModule.State private menuChannel;

  private dialog: boolean = false;
  private applyType: any = {};
  private otherModel = {
    caseHaltCategory: CASE_HALT_CATEGORY.CASE_HALT
  };
  private fromChannel: any = "";
  private disabledType: any = [];

  private onClickButton() {
    this.applyType = ApplyType.assist;
    const channelsVisit = [
      MENU_CHANNEL.Visit_team,
      MENU_CHANNEL.Visit_personal
    ];
    const channelsTel = [MENU_CHANNEL.Tel_team, MENU_CHANNEL.Tel_personal];
    const channelsLegal = [
      MENU_CHANNEL.Legal_team,
      MENU_CHANNEL.Legal_personal
    ];
    if (channelsVisit.includes(this.menuChannel)) {
      this.disabledType = ["ASSIT_VISIT"];
    }
    if (channelsTel.includes(this.menuChannel)) {
      this.disabledType = ["ASSIT_TEL"];
    }
    if (channelsLegal.includes(this.menuChannel)) {
      this.disabledType = ["ASSIT_LEGAL"];
    }
    this.dialog = true;
  }
}
</script>
<style lang="less" scope></style>
